import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.util.ArrayList;


public class sm2 {

	static BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
	//static BufferedReader reader;		
	
	public static void main(String[] args) throws Exception {
		//reader = new BufferedReader(new FileReader("salesman_input.txt"));
		new sm2().run();
	}

	void runBellmanFordRun(int origin, int destination, ArrayList<int[]> al, int[] amounts){
		int towns = amounts.length;
		long[] d = new long[towns];
		int[] pre = new int[towns];
		
		for(int i=0; i< towns; i++){
			d[i] = Integer.MIN_VALUE;
			pre[i] = -1;
		}
		d[origin] = 0;
		for(int i=1; i < towns; i++)
			for( int[] ia: al )
				if(  d[ ia[0] ] != Integer.MIN_VALUE    &&     (d[ ia[0] ] - ia[2] + amounts[ ia[1] ]  >  d[ ia[1] ] )   ){  
					d[ ia[1] ] = d[ ia[0] ] - ia[2] + amounts[ ia[1] ] ;
					pre[ ia[1] ] = ia[0];
				}
			
		if(d[destination] == Integer.MIN_VALUE){
			System.out.println("IMPOSSIBLE");
			return;
		}
		
		ArrayList<Integer> list = new ArrayList<Integer>();
		int value = pre[destination];
		boolean endless = true;
		while(!list.contains(value)){
			if(value == -1){endless = false; break;}
			list.add(value);
			value = pre[value];
		}
		
		if(!endless){
			System.out.println("BEST PROFIT: "+ d[destination]);
			return;
		}
		
		for( int[] ia: al )
			if( d[ ia[0] ] != Integer.MIN_VALUE    &&     (d[ ia[0] ] - ia[2] + amounts[ ia[1] ]  >  d[ ia[1] ] ) ){  System.out.println("ENDLESS PROFIT"); return;  }
	}
	
	void run() throws Exception{
		String line = reader.readLine();
		if(line.equals("END")) {reader.close(); return;}
		String[] split = line.split(" ");
		int towns = Integer.parseInt(split[0]);
		int roads = Integer.parseInt(split[1]);
		int origin = Integer.parseInt(split[2]);
		int destination = Integer.parseInt(split[3]);
			
		line = reader.readLine();
		String[] splitamounts = line.split(",");
		int[] amounts = new int[towns];
		for(int i=0; i< towns;i++)
			amounts[i] = Integer.parseInt(splitamounts[i]);
		
		int[][] inta = new int[roads][];
		ArrayList<int[]> al = new ArrayList<int[]>();
		for(int i = 0; i< roads; i++){
			line = reader.readLine();
			split = line.split(" ");
			int[] intsplit = new int[split.length]; 
			for(int j=0; j< split.length;j++)
				intsplit[j] = Integer.parseInt(split[j]);
			inta[i] = intsplit;
			al.add(intsplit);
		}
		new sm2().runBellmanFordRun(origin, destination, al, amounts);
		new sm2().run();
	}
	
}